//
//  WTLoginView.m
//  OneDay
//
//  Created by lanou on 16/1/19.
//  Copyright © 2016年 小明. All rights reserved.
//

#import "WTLoginView.h"

#define kMargin 10 * kRelativeLength_X
@implementation WTLoginView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // 用户
        _userImageV = [[UIImageView alloc]initWithFrame:CGRectMake(kMargin, 30 * kRelativelength_Y, 20 * kRelativeLength_X, 20 * kRelativelength_Y)];
        [self addSubview:_userImageV];
        
        _userTF = [[UITextField alloc]initWithFrame:CGRectMake(_userImageV.right + 15 * kRelativeLength_X, _userImageV.top, kScreenWidth - _userImageV.right - 15 * kRelativeLength_X, _userImageV.height)];
        _userTF.clearButtonMode = UITextFieldViewModeAlways;
        _userTF.delegate = self;
        [self addSubview:_userTF];
        
        UIImageView * bottoViewOne = [[UIImageView alloc]initWithFrame:CGRectMake(0, _userImageV.bottom + 19 * kRelativelength_Y, kScreenWidth, kRelativelength_Y)];
        bottoViewOne.backgroundColor = [UIColor grayColor];
        [self addSubview:bottoViewOne];
        

        
        
        // 密码
        _passwordImageV = [[UIImageView alloc]initWithFrame:CGRectMake(kMargin, bottoViewOne.bottom + 20 * kRelativelength_Y, 20 * kRelativeLength_X, 20 * kRelativelength_Y)];
        [self addSubview:_passwordImageV];
        
        _passwordTF = [[UITextField alloc]initWithFrame:CGRectMake(_passwordImageV.right + 15 * kRelativeLength_X, _passwordImageV.top, kScreenWidth - _passwordImageV.right - 15 * kRelativeLength_X, _passwordImageV.height)];
        _passwordTF.delegate = self;
        _passwordTF.clearButtonMode = UITextFieldViewModeAlways;
        _passwordTF.secureTextEntry = YES;
        [self addSubview:_passwordTF];
        
        UIImageView * bottoViewTwo = [[UIImageView alloc]initWithFrame:CGRectMake(0, _passwordImageV.bottom + 19 * kRelativelength_Y, kScreenWidth, kRelativelength_Y)];
        bottoViewTwo.backgroundColor = [UIColor grayColor];
        [self addSubview:bottoViewTwo];

        
        
        // 登录
        _loginButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _loginButton.frame = CGRectMake((kScreenWidth - 200 * kRelativeLength_X) / 2, bottoViewTwo.bottom + kMargin, 200 * kRelativeLength_X, 60 * kRelativelength_Y);
        _loginButton.backgroundColor = [UIColor grayColor];
        [_loginButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
        [self addSubview:_loginButton];
        
        
        // 注册
        _registerButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _registerButton.frame = CGRectMake(_loginButton.left, _loginButton.bottom + 20 * kRelativelength_Y, _loginButton.width, _loginButton.height);
        _registerButton.backgroundColor = [UIColor grayColor];
        [_registerButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
        [self addSubview:_registerButton];
        
        
    }
    return self;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
